#include "qfont.h"

QNamespaceStart(Qui)

void QFontDrawCell::draw()
{
	appy_attribute();
	appy_font_style();

	font_image = IMAGE(font_image.getwidth(), font_image.getheight());

	SetWorkingImage(&font_image);

	if (text_position == TextLocatedLeft)
	{
		QOutTextXy(0, 0, (WCHAR*)text_string.c_str());
	}
	if (text_position == TextLocatedCentral)
	{
		QOutTextCenter(&font_image, text_string.c_str(), true);
	}
	if (text_position == TextLocateCenter)
	{
		QOutTextCenter(&font_image, text_string.c_str(), false);
	}
	if (text_position == TextLocatedRight)
	{
		QOutTextXy(font_image.getwidth() - QTextWidth(text_string.c_str()), 
			0, (WCHAR*)text_string.c_str());
	}

	Qui::QRenderimageAlpha(&font_image);

	SetWorkingImage(NULL);

	if (show_image == true)
	{
		QPutimage(get_x(), get_y(), &font_image);
	}

	restore_font_style();
	restore_attribute();
}

QNamespaceEnd